package com.inno.life.infra.basic.service.impl;

import com.github.pagehelper.Page;
import com.inno.life.infra.basic.mapper.PlannerMomentDao;
import com.inno.life.infra.basic.entity.PlannerMoment;
import com.inno.life.infra.basic.service.PlannerMomentService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * (PlannerMoment)表服务实现类
 *
 * @author makejava
 * @since 2024-11-18 20:00:24
 */
@Service("plannerMomentService")
public class PlannerMomentServiceImpl implements PlannerMomentService {
    @Resource
    private PlannerMomentDao plannerMomentDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public PlannerMoment queryById(Long id) {
        return this.plannerMomentDao.queryById(id);
    }


    /**
     * 新增数据
     *
     * @param plannerMoment 实例对象
     * @return 实例对象
     */
    @Override
    public PlannerMoment insert(PlannerMoment plannerMoment) {
        this.plannerMomentDao.insert(plannerMoment);
        return plannerMoment;
    }

    /**
     * 修改数据
     *
     * @param plannerMoment 实例对象
     * @return 实例对象
     */
    @Override
    public void update(PlannerMoment plannerMoment) {
        this.plannerMomentDao.update(plannerMoment);
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long id) {
        return this.plannerMomentDao.deleteById(id) > 0;
    }

    @Override
    public Page<PlannerMoment> queryPage(PlannerMoment entity) {

        return this.plannerMomentDao.queryPage(entity);
    }

    @Override
    public void incrementLikeCount(Long toMomentId) {
        this.plannerMomentDao.incrementLikeCount(toMomentId);
    }

    @Override
    public void decrementLikeCount(Long toMomentId) {
        this.plannerMomentDao.decrementLikeCount(toMomentId);
    }

    @Override
    public void incrementCommentCount(Long momentId) {
        this.plannerMomentDao.incrementCommentCount(momentId);
    }

    @Override
    public void decrementCommentCount(Long id) {
        this.plannerMomentDao.decrementCommentCount(id);
    }

    @Override
    public void incrementViewCount(PlannerMoment moment4db) {
        this.plannerMomentDao.incrementViewCount(moment4db.getId());
    }

    @Override
    public List<PlannerMoment> queryRecommend() {
        return this.plannerMomentDao.queryRecommend();
    }

    @Override
    public List<Long> queryUserId() {
        return this.plannerMomentDao.queryUserId();
    }
}
